<?php


namespace app\voip\controller;



use app\voip\func\CallFunc;
use vae\controller\AdminCheckAuth;

class CallController extends AdminCheckAuth
{
    public function index()
    {
        return view();
    }
    public function ajaxGetList()
    {

        if (!request()->isAjax()){return view('index');}
        $where = array();
        $param = vae_get_param();

        if(!empty($param['keywords'])) {
            $where['id|intro'] = ['like', '%' . $param['keywords'] . '%'];
        }
        $where['aid']=vae_get_login_admin('id');
        $rows = empty($param['limit']) ? \think\Config::get('paginate.list_rows') : $param['limit'];
        return vae_assign_table(0,'',CallFunc::getList($where,$rows,$param));
    }


    public function add()
    {
        return view();
    }
    public function addData()
    {
        try{
            $validate=validate('CallAuth');
            if (!$validate->scene(__FUNCTION__)->check(input())){
                throw new \Exception($validate->getError());
            }
            $data=input();
            $data['uniqid']='K'.date("YmdHis").uniqid();
            $data['aid']=vae_get_login_admin('id');
            CallFunc::addInfo($data);
        }catch (\Exception $e){
            return vae_assign(0,$e->getMessage());
        }
        return vae_assign();
    }
    public function edit($id)
    {
        $info=CallFunc::getGroupInfo(['id'=>$id]);
        return view('',['info'=>$info]);
    }
    public function editData()
    {
        try{
            $info=CallFunc::update(input());
        }catch (\Exception $e){
            return vae_assign(0,$e->getMessage());
        }
        return vae_assign();
    }
}